﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace ConsoleHoster.View.Controls
{
	/// <summary>
	/// Interaction logic for TextBoxWithActionButton.xaml
	/// </summary>
	public partial class TextBoxWithActionButton : UserControl
	{
		public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(TextBoxWithActionButton), new PropertyMetadata(null));
		private Action buttonAction;

		public TextBoxWithActionButton()
		{
			this.InitializeComponent();
		}

		private void btnAction_Click(object sender, RoutedEventArgs e)
		{
			Action tmpAction = this.ButtonAction;
			if (tmpAction != null)
			{
				tmpAction();
			}
		}

		public string Text
		{
			get
			{
				return (string)this.GetValue(TextProperty);
			}
			set
			{
				this.SetValue(TextProperty, value);
			}
		}

		public Action ButtonAction
		{
			get
			{
				return this.buttonAction;
			}
			set
			{
				this.buttonAction = value;
			}
		}

		protected Button Button
		{
			get
			{
				return this.btnAction;
			}
		}
	}
}